﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPO
{
  public static  class DynamicData
    {
      public static DataTable GetMasterData(string masterType)
      {
          DAO.DAO d = new DAO.DAO();
          List<SqlParameter> param = new List<SqlParameter>();
          param.Add(d.AddParameter("@MasterType", masterType));
          return d.ExecuteDataSet("P_GetMasterData", param).Tables[0];
      }
      public static DataTable GetAppData(string tableName)
      {
          DAO.DAO d = new DAO.DAO();
          List<SqlParameter> param = new List<SqlParameter>();
          param.Add(d.AddParameter("@TableName", tableName));
          return d.ExecuteDataSet("P_GetAppData", param).Tables[0];
      }

      internal static DataTable GetData(string tableName, string type)
      {
         if(type=="M")
             return GetMasterData(tableName);
         if (type == "A")
             return GetAppData(tableName);
         else return null;
      }
    }
}
